package com.yms.lock;

/**
 * @version : 1.0
 * @author: yangmingsong
 * @date: 2022/7/8-07-08-16:05
 * @description: spring5Test 乐观锁  悲观锁
 */
public class OptimisticPessimisticLock {

    public static void main(String[] args) {
        ResourcePhone phone = new ResourcePhone();

/*        new Thread(()->{
            phone.sendMail();
        }).start();

        new Thread(() -> {
            phone.writeMail("123456");
        }).start();*/



    }
}

/**
 * 乐观锁
 */
class OptimisticLock {

}

/**
 * 悲观锁
 */
class PessimisticLock{

}

/**
 * 资源类---手机
 */
class ResourcePhone {
    private String mail;

    public void sendMail(){
        System.out.println(mail);
    }

    public void writeMail(String mail){
        this.mail = mail;
    }
}